Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLR hosting #9572

Draft
wants to merge 86 commits into
base: main
Choose a base branch
from
Draft

CLR hosting #9572

wants to merge 86 commits into from

Conversation

grendello
Copy link
Contributor

@grendello grendello commented Dec 2, 2024

No description provided.

@grendello grendello force-pushed the dev/grendel/clr-host branch from cbc08f4 to 0370d7d Compare December 3, 2024 12:41
@grendello grendello force-pushed the dev/grendel/clr-host branch 2 times, most recently from c085352 to 13bbd93 Compare December 3, 2024 21:15
Comment on lines 42 to 45
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.debug.so" />
<_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release.so" />
<_AndroidRuntimePackAssets Condition=" Exists('$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.debug.so') " Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.debug.so" />
<_AndroidRuntimePackAssets Condition=" Exists('$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release.so') " Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libmono-android.release.so" />
<_AndroidRuntimePackAssets Condition=" Exists('$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libnet-android.debug.so') " Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libnet-android.debug.so" />
<_AndroidRuntimePackAssets Condition=" Exists('$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libnet-android.release.so') " Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libnet-android.release.so" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fixing this up in #9583, but maybe I can split up part of it into a smaller PR.

@grendello grendello force-pushed the dev/grendel/clr-host branch from 13bbd93 to 82cfb8a Compare December 4, 2024 18:47
  * Add a version script which hides all the symbols except for the
    handful we have to export.
  * Enable exceptions
* main:
  [native] Use libc++ (#9558)
  [ci] Fail build if any git tracked files were modified. (#9661)
  Localized file check-in by OneLocBuild Task (#9663)
The build is broken atm, need to move things around a bit.
* main:
  Bump to dotnet/sdk@2d6bc4f67d 10.0.100-alpha.1.25060.8 (#9669)
  [templates] Default `$(SupportedOSPlatformVersion)=24`. (#9656)
  Bump to dotnet/sdk@a93a592ce9 10.0.100-alpha.1.25056.1 (#9395)
  LEGO: Pull request (#9667)
  [tests] use the 'TestName' property (#9664)
* main:
  Localized file check-in by OneLocBuild Task: Build definition ID 17928: Build ID 10814362 (#9673)
* main:
  [ci] Add template for setting JAVA_HOME vars (#9671)
  Bump com.android.tools.build:manifest-merger from 31.7.3 to 31.8.0 (#9678)
  Bump to dotnet/sdk@2dd591056f 10.0.100-alpha.1.25062.16 (#9679)
  Bump com.android.tools:r8 from 8.5.35 to 8.7.18 (#9677)
  Bump to dotnet/java-interop@4f06201 (#9676)
  Bump to dotnet/android-api-docs@492e524d (#9668)
  [build] Support JDK-21 (#9672)
At least files end up where they should be :P
* main:
  [illink] consolidate & remove hardcoded assembly names (#9662)
  Bump to NuGet/NuGet.Client@aa7eb998 (#9682)
  [Microsoft.Android.Sdk.Analysis] fix global types (#9680)
@@ -216,5 +218,6 @@
<ItemGroup>
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="Mono" />
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="NativeAOT" />
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="CoreCLR" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out if we should case it CoreClr or CoreCLR:

I found both, so we can probably decide which we prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like CoreCLR better, since CLR is an acronym

Comment on lines 237 to 240
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'Mono' Or '$(AndroidRuntime)' == '' " Include="libnet-android.debug" />
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'Mono' Or '$(AndroidRuntime)' == '' " Include="libnet-android.release" />
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'CoreCLR' " Include="libmono-android.debug" />
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'CoreCLR' " Include="libmono-android.release" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, $(AndroidRuntime) isn't defined for customer's project builds. I think it would always be blank?

Right now, we only have these:

  • $(UseMonoRuntime)=true
  • $(_AndroidNativeAot)=true

Maybe we need to figure out what property xamarin/xamarin-macios uses to identify CoreCLR? You can use it for macOS, to choose between Mono & CoreCLR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would always be blank now and I think we should always expect a value in there. The macios way looks fine.

Comment on lines 301 to 302
<_AndroidUseCLR Condition=" '$(AndroidRuntime)' == 'CoreCLR' ">True</_AndroidUseCLR>
<_AndroidUseCLR Condition=" '$(AndroidRuntime)' != 'CoreCLR' ">False</_AndroidUseCLR>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(AndroidRuntime) is probably always blank in customer's Android projects, but is this the property to select a runtime? Should the property be in DefaultProperties.targets?

Maybe we should align with xamarin/xamarin-macios?

@jonathanpeppers
Copy link
Member

Ok, here is what we should do for MSBuild properties for now:

  • $(_AndroidRuntime) is the property we use throughout Android project builds (customer projects), it can say MonoVM, NativeAOT, or CoreCLR. It is a private property.
  • If PublishAot=true, $(_AndroidRuntime)=NativeAOT
  • If UseMonoRuntime=false, $(_AndroidRuntime)=CoreCLR
  • If $(UseMonoRuntime)="", we default to $(UseMonoRuntime)=true in DefaultProperties.targets
  • If UseMonoRuntime=true, $(_AndroidRuntime)=MonoVM

We could remove $(_AndroidNativeAot) and check '$(_AndroidRuntime)' == 'NativeAOT' instead. If we keep it, we should introduce $(_AndroidCoreClr).

@grendello
Copy link
Contributor Author

Ok, here is what we should do for MSBuild properties for now:

* `$(_AndroidRuntime)` is the property we use throughout Android project builds (customer projects), it can say `MonoVM`, `NativeAOT`, or `CoreCLR`. It is a private property.

* If `PublishAot=true`, `$(_AndroidRuntime)=NativeAOT`

* If `UseMonoRuntime=false`, `$(_AndroidRuntime)=CoreCLR`

* If `$(UseMonoRuntime)=""`, we default to `$(UseMonoRuntime)=true` in `DefaultProperties.targets`

* If `UseMonoRuntime=true`, `$(_AndroidRuntime)=MonoVM`

We could remove $(_AndroidNativeAot) and check '$(_AndroidRuntime)' == 'NativeAOT' instead. If we keep it, we should introduce $(_AndroidCoreClr).

I like $(_AndroidRuntime) for this, it's much leaner and reads better IMO :)

jonathanpeppers added a commit that referenced this pull request Jan 15, 2025
Context: #9572 (comment)
Context: https://github.com/xamarin/xamarin-macios/blob/2009c571aa8a975ab0e0b1785e5484dbd64d6f9b/dotnet/targets/Xamarin.Shared.Sdk.targets#L1004-L1006

To align with xamarin/xamarin-macios, the following public MSBuild
properties can be used to select a runtime for iOS, macOS, etc.:

* `$(UseMonoRuntime)=true`: MonoVM
* `$(UseMonoRuntime)=false`: CoreCLR
* `$(PublishAot)=true`: NativeAOT
* Defaults if blank, select MonoVM

Introduce a private `$(_AndroidRuntime)` property we can use
throughout our build to know which runtime is being targetted.

This way, if a new property is designed in the future, we can keep
using `$(_AndroidRuntime)` and simply update the defaults.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants